/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.imenu.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author yunzi
 */
@Entity
@Table(name = "imenu_favorite")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ImenuFavorite.findAll", query = "SELECT i FROM ImenuFavorite i"),
    @NamedQuery(name = "ImenuFavorite.findById", query = "SELECT i FROM ImenuFavorite i WHERE i.id = :id"),
    @NamedQuery(name = "ImenuFavorite.findByCustomerId", query = "SELECT i FROM ImenuFavorite i WHERE i.customerId = :customerId"),
    @NamedQuery(name = "ImenuFavorite.findByMenuId", query = "SELECT i FROM ImenuFavorite i WHERE i.menuId = :menuId"),
    @NamedQuery(name = "ImenuFavorite.findFavoritesByDeviceId", query = "SELECT i FROM ImenuFavorite i WHERE i.customerId = (select c.id FROM ImenuCustomer c where c.deviceId=:deviceId)"),
    @NamedQuery(name = "ImenuFavorite.findFavoriteMenuIdsByDeviceId", query = "SELECT i.menuId FROM ImenuFavorite i WHERE i.customerId = (select c.id FROM ImenuCustomer c where c.deviceId=:deviceId)")})
public class ImenuFavorite implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", insertable = false)
    private Integer id;
    @Column(name = "customer_id")
    private Integer customerId;
    @Column(name = "menu_id")
    private Integer menuId;
    @Transient
    private ImenuMenu menu;
    public ImenuFavorite() {
    }

    public ImenuFavorite(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public ImenuMenu getMenu() {
        return menu;
    }

    public void setMenu(ImenuMenu menu) {
        this.menu = menu;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public Integer getMenuId() {
        return menuId;
    }

    public void setMenuId(Integer menuId) {
        this.menuId = menuId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ImenuFavorite)) {
            return false;
        }
        ImenuFavorite other = (ImenuFavorite) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.imenu.entity.ImenuFavorite[ id=" + id + " ]";
    }
    
}
